package com.example.social.screen

import android.util.Log
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavHostController
import com.example.social.item_view.ThreadListPage
import com.example.social.screen.component.NotThreadList
import com.example.social.viewmodel.HomeViewModel

@Composable
fun Home(navHostController: NavHostController,navController: NavHostController?) {
    val homeViewModel: HomeViewModel = viewModel()
    val threadAndUser by homeViewModel.threadsAndUsers.observeAsState(null)

    Log.d("Home", "threadAndUser data: $threadAndUser")

    if (threadAndUser==null) {
        NotThreadList("暂无用户发布话题")
    }else{
        if (navController != null) {
            ThreadListPage(threadAndUser!!, navHostController = navController)
        }
    }
}


